Ext.define('HIT.view.ApplyFormCustomerPanel', {
    extend: 'Ext.form.Panel',
    alias: 'widget.applyformcustomerpanel',
    id   : 'panel-applyformcustomerpanel',
    frame: false,
	layout: {
		type: 'anchor'
	},
	initComponent: function() {
		var me = this;
		Ext.applyIf(me, {
			items: [
				{
					xtype: 'gridpanel',
					id:'applyFormCustomerPanel',
					anchor : '100% 100%',
					columnLines: false,
					autoScroll: true,
					store : 'ApplyFormCustomerStore',
					columns: [
						{
							xtype: 'rownumberer',
							resizable: true,
							width: 30
						},
						{
							xtype: 'gridcolumn',
							width: 160,
							align: 'center',
							dataIndex : 'code',
							text: Share.T('客户代码')
						},
						{
							xtype: 'gridcolumn',
							width: 200,
							align: 'center',
							dataIndex : 'client_supplier',
							text: Share.T('客户名称')
						}
					],
					viewConfig: {
						enableTextSelection:true
					},
					selModel: Ext.create('Ext.selection.CheckboxModel', {
						mode : 'single',
						checkOnly: false
					}),
					dockedItems: [
					{
						xtype: 'pagingtoolbar',
						dock: 'bottom',
						id:'pageApplyFormCustomer',
						width: 360,
						inputItemWidth:45,
						displayInfo: true,
						store : 'ApplyFormCustomerStore',
						plugins: [{
							ptype: "pagesize",
							uxPageSize: page_size}]
					},{
				    	xtype: 'toolbar',
						dock: 'top',
						items: [
						    {
						    	xtype: 'tbspacer',
						        width: 20
						    },
						    {
						    	xtype: 'textfield',
						    	labelwidth:40,
								width:234,
						    	id: 'tbxApplyFormCustomerSearch',
						    	fieldLabel: Share.T('信息查询'),
						    	name: 'client-info-search',
						    	listeners:{
						    		specialkey : function(field, e) {  
					                     if (e.getKey() == Ext.EventObject.ENTER) {  
					                    	Ext.getCmp('tbxApplyFormCustomerSearch').fireEvent("click");
					                     }  
					                 }
						    	}
						    },
						    {
						    	xtype: 'tbspacer',
						        width: 20
						    },
						    {
						    	xtype: 'button',
						    	id:'btnApplyFormCustomerSearch',
						    	text: Share.T('查询'),
						    	listeners: {
						    			click: {
						    				fn: me.onApplyFormCustomerPanelSearch,
						                    scope: me
						    			}
						    	}
						    }
						]
				    }
					]
				}
			]
		});
		me.callParent(arguments);
	},
	
    onApplyFormCustomerPanelSearch: function(btn,event,eOpts){
    	var searchInfo = Ext.getCmp('tbxApplyFormCustomerSearch').getValue();
    	var ClientStore = Ext.getCmp('applyFormCustomerPanel').getStore();
    	if(!searchInfo){
    		ClientStore.load();
    	}else{
    		ClientStore.load({
    			params: {searchInfo:searchInfo},
    			callback: function(records, options, success){
    				if(!records[0]){
    					Share.ShowMessage("I0051");
    				}
    			},
    		    scope: ClientStore,
    		    add: true
    		});
    	}
    }
    
});